use serde::{Serialize, Deserialize};

#[derive(Serialize, Deserialize, Debug)]
struct Point {
    x: i32,
    y: i32,
}

#[cfg(test)]
mod test {
    use super::*;

    #[test]
    fn point_json(){
        let point = Point{ x: 1, y: 2};
        let serialized = serde_json::to_string(&point).unwrap();
        assert_eq!(r#"{"x":1,"y":2}"#, serialized);
        //println!("serialized = {}", serialized);

        let deserialized: Point = serde_json::from_str(&serialized).unwrap();
        assert_eq!(1, deserialized.x);
        assert_eq!(2, deserialized.y);
        //println!("deserialized = {:?}", deserialized);
    }
}
